﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.Xml;
using Honestysoft.Baseframework.WebUI;

namespace Honestysoft.Financing.WebUI.Apply
{
    public partial class test2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write("本周第一天：" + DateTimeByWeek(2012, 23).ToString("yyyy-MM-dd"));
            Response.Write(Request.Url.AbsoluteUri);
            Response.Write("<br/>");
            Response.Write(Request.Url.AbsolutePath);
            Response.Write("<br/>");
            Response.Write(Request.Url.Host);
            Response.Write("<br/>");
            Response.Write(Request.Url.PathAndQuery);
            Response.Write("<br/>");
            Response.Write(Request.ApplicationPath);
            Response.Write("<br/>");
            Response.Write(Request.CurrentExecutionFilePath);
            Response.Write("<br/>");
            Response.Write(Page.ResolveClientUrl("~/Reports/blank.doc"));
            Response.Write("<br/>");
            Response.Write(Page.ResolveUrl("~/Reports/blank.doc"));
            Response.Write("<br/>");
            Response.Write(Page.ResolveClientUrl(Globals.Home + "Reports/blank.doc"));
            Response.Write("<br/>");
            Response.Write(Page.ResolveUrl(Globals.Home+"Reports/blank.doc"));
            Response.Write("<br/>");
            Response.Write(Request.Url.OriginalString);
            Response.Write("<br/>");
            Response.Write(Request.RawUrl);
            Response.Write("<br/>");

            string fileName = "acsadfasdf.doc";
            Response.Write(fileName.Substring(fileName.LastIndexOf(".") + 1));
        }

        public static DateTime DateTimeByWeek(int year, int week)
        {

            DateTime dt = new DateTime();

            dt = Convert.ToDateTime(year + "-01-01");

            dt = dt.AddDays(-Convert.ToInt32(dt.DayOfWeek) + 1);

            // dd获取当日所在第几周

            int dd = System.Globalization.CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(Convert.ToDateTime(year + "-01-01"), System.Globalization.CalendarWeekRule.FirstFullWeek, 0);

            //获取当年第一周日期

            dt = dt.AddDays(-(dd - 1) * 7);

            //获取第week周的第一天日期

            dt = dt.AddDays((week - 1) * 7);

            return dt;

        }


    }
}